import time
from selenium import webdriver
from selenium.webdriver.common.by import By

option = webdriver.ChromeOptions()
user_data_dir = r'--user-data-dir=C:\Users\1\AppData\Local\Google\Chrome\User Data'
option.add_argument(user_data_dir)
driver = webdriver.Chrome(options = option)
driver.get('https://mail.163.com')
time.sleep(2)
send = driver.find_element(By.ID,'_mail_component_78_78')
send.click()
time.sleep(1)
sendto =driver.find_element(By.CSS_SELECTOR,'input[class="nui-editableAddr-ipt"]')
sendto.send_keys("1546001409@qq.com")
time.sleep(2)
theme = driver.find_element(By.CSS_SELECTOR,'div[aria-label="邮件主题输入框，请输入邮件主题"] input[class="nui-ipt-input"]')
theme.send_keys('蔡徐坤')
time.sleep(2)
frame =driver.find_element(By.CSS_SELECTOR,'iframe[class="APP-editor-iframe"]')
driver.switch_to.frame(frame)
body = driver.find_element(By.CSS_SELECTOR,'body')
body.send_keys('你干嘛')
time.sleep(2)
driver.switch_to.default_content()
upload = driver.find_element(By.CSS_SELECTOR,'div[class="fv0"] input[class="O0"]')
upload.send_keys(r'C:\Users\1\Desktop\tu\b17eca8065380cd79123caf75208ba345982b2b72bde.jpg')
buttonsend = driver.find_element(By.CSS_SELECTOR,'footer[class="jp0"] span')
buttonsend.click()
time.sleep(4)
